<template>
  <div class="stats-section">
    <h2 class="section-title">测试案例统计</h2>
    <div class="stats-grid">
      <div 
        v-for="stat in testStats" 
        :key="stat.id"
        class="stat-card"
        :class="stat.type"
      >
        <div class="stat-content">
          <div class="stat-info">
            <div class="stat-icon">
              <i :class="stat.icon"></i>
            </div>
            <h3 class="stat-title">{{ stat.title }}</h3>
          </div>
          <div class="stat-number-container">
            <div class="stat-number">{{ stat.count }}</div>
            <div class="stat-trend">
              <i :class="stat.trendIcon"></i>
              <span>{{ stat.trend }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TestStatsSection',
  setup() {
    const testStats = [
      {
        id: 'ui',
        title: 'UI自动化案例',
        count: 156,
        icon: 'fas fa-desktop',
        type: 'ui-automation',
        trend: '+12%',
        trendIcon: 'fas fa-arrow-up'
      },
      {
        id: 'api',
        title: '接口自动化案例',
        count: 89,
        icon: 'fas fa-plug',
        type: 'api-automation',
        trend: '+8%',
        trendIcon: 'fas fa-arrow-up'
      },
      {
        id: 'ai',
        title: 'AI生成测试案例',
        count: 234,
        icon: 'fas fa-robot',
        type: 'ai-generated',
        trend: '+25%',
        trendIcon: 'fas fa-arrow-up'
      }
    ]

    return {
      testStats
    }
  }
}
</script>

<style scoped>
.stats-section {
  margin-bottom: 25px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  aspect-ratio: 1/1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 1;
}

.ui-automation::before {
  background: #4361ee; /* 蓝色 */
}

.api-automation::before {
  background: #f59e0b; /* 橙色 */
}

.ai-generated::before {
  background: #10b981; /* 绿色 */
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.stat-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  text-align: center;
}

.stat-number-container {
  position: relative;
  text-align: center;
  width: 100%;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.ui-automation .stat-icon {
  background: #4361ee; /* 蓝色 */
  color: white;
}

.api-automation .stat-icon {
  background: #f59e0b; /* 橙色 */
  color: white;
}

.ai-generated .stat-icon {
  background: #10b981; /* 绿色 */
  color: white;
}

.stat-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  margin-bottom: 16px;
}

.stat-title {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  margin-top: 12px;
  text-align: center;
}

.stat-number {
  font-size: 48px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
  letter-spacing: -0.5px;
  position: relative;
  margin-bottom: 8px;
}

.ui-automation .stat-number {
  color: #4361ee; /* 蓝色 */
}

.api-automation .stat-number {
  color: #f59e0b; /* 橙色 */
}

.ai-generated .stat-number {
  color: #10b981; /* 绿色 */
}

.stat-trend {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #10b981; /* 绿色，表示增长趋势 */
  font-weight: 500;
  margin-top: 4px;
}

.stat-trend i {
  margin-right: 4px;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-number {
    font-size: 36px;
  }
  
  .stat-card {
    aspect-ratio: 1/1;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
    aspect-ratio: 1/1;
  }
  
  .stat-number {
    font-size: 36px;
  }
  
  .stat-title {
    font-size: 16px;
    margin-top: 8px;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    aspect-ratio: auto;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .stat-content {
    flex-direction: row; /* 保持水平布局 */
  }
  
  .stat-title {
    font-size: 14px; /* 小屏幕下稍微减小字体 */
  }
  
  .stat-icon {
    width: 36px;
    height: 36px;
    margin-right: 8px;
  }
  
  .stat-number {
    font-size: 32px; /* 小屏幕下稍微减小数字大小 */
  }
  
  .stat-trend {
    font-size: 11px;
  }
}
</style>